﻿using System;
using System.ComponentModel;
using System.Windows;

using Microsoft.Practices.Composite.Regions;

using SupremacyEditor.Services;

namespace SupremacyEditor
{
    /// <summary>
    /// Interaction logic for Shell.xaml
    /// </summary>
    public partial class Shell : IShellView
    {
        private readonly ITextService _textService;

        public Shell(ITextService textService)
        {
            if (textService == null)
                throw new ArgumentNullException("textService");

            _textService = textService;

            StringResourceProvider.SetProvider(this, new StringResourceProvider(_textService));

            InitializeComponent();

            this.Width = SystemParameters.WorkArea.Width * 3 / 4;
            this.Height = SystemParameters.WorkArea.Height * 3 / 4;
        }

        public IRegionManager RegionManager
        {
                get { return Microsoft.Practices.Composite.Presentation.Regions.RegionManager.GetRegionManager(this); }
        }

        public void ShowView()
        {
            this.Show();
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            if (e.Cancel)
                return;
            EditorEvents.EditorClosing.Publish(e);
        }
    }
}
